import "./index.scss";
import Context from "../../context";
import { useContext } from "react";
const CartCounter = ({ id, goods_count }) => {
  // @ts-ignore
  const { onChangeGoodsCount } = useContext(Context);
  return (
    <div className="my-counter">
      <button
        onClick={() => onChangeGoodsCount(id, goods_count - 1)}
        type="button"
        className="btn btn-light"
      >
        -
      </button>
      <input
        type="number"
        className="form-control inp"
        value={goods_count}
        onChange={(e) => onChangeGoodsCount(id, +e.target.value)}
      />
      <button
        onClick={() => onChangeGoodsCount(id, goods_count + 1)}
        type="button"
        className="btn btn-light"
      >
        +
      </button>
    </div>
  );
};

export default CartCounter;
